package com.kang.c0c.tree.node;

import com.kang.c0c.symbol.Symbol;

/**
 * 抽象语法树的所有节点的父类，只定义了这个节点的类型node
 * node是一个整数，它的含义由接口com.kang.c0c.tree.Nodes定义
 *
 * @author kang
 *
 * Feb 6, 2009
 */
public class Node {
	private int node;
	private int use;
	
	public Node(){
		super();
	}

	public Node(int node){
		super();
		this.node = node;
		this.use = 0;
	}
	
	public int getNode() {
		return node;
	}

	public void setNode(int node) {
		this.node = node;
	}
	
	public int getUse(){
		return use;
	}
	
	public void incUse(){
		this.use ++;
		if(node == Nodes.VAR){
			LeafNode leaf = (LeafNode)this;
			Symbol sym = (Symbol)leaf.getValue();
			sym.incUse();
		}
	}
	
	public void decUse(){
		this.use --;
		if(node == Nodes.VAR){
			LeafNode leaf = (LeafNode)this;
			Symbol sym = (Symbol)leaf.getValue();
			sym.decUse();
		}
	}
}
